function drop(event) {
		event.target.innerHTML = "";
		event.preventDefault();
		var files = event.dataTransfer.files;
		if (files.length == 0) {
			files = event.dataTransfer.items;
		}
		
		var doneCount = 0;
		for(var i = 0; i<files.length; i++) {
			if(files[i].type.substring(0,5) == 'image') {
				var reader = new FileReader();
				
				reader.onload = function(e) {
					var div = document.createElement('div');
					div.style.float = 'left';
					div.disabled = true;
					
					var i = document.createElement('i');
					i.innerHTML = "x";
					i.style.fontStyle = 'unset';
					i.style.verticalAlign = 'super';
					i.onclick = function () {
						var currDiv = div;
						var containDiv = event.target;
						containDiv.removeChild(currDiv);
					};
				
					var img = document.createElement('img');
					img.src= e.target.result;
					img.height = 20;
					img.width = 30;
					
					div.appendChild(img);
					div.appendChild(i);
					
					event.target.appendChild(div);
					// console.log(e.target.result);
					
					doneCount++;
					console.log(doneCount);
					document.getElementById("showtext").innerHTML=doneCount;
					if (doneCount == files.length) {
						document.getElementById("showtext").innerHTML="All done!";
						console.log("Done it!");
					}
				}
				reader.readAsDataURL(files[i]);
			}
			
			if (files[i].type == 'text/plain') {
				if (!!files[i].getAsString) {
					files[i].getAsString(function (s){
						var ele = document.getElementById(s);
						if(!!ele) {
							event.target.appendChild(ele); // 不可自包含
						} else {
							event.target.innerHTML += s;
						}
					 });
				}
			}
		}
		
		
}
function dragstart(event) {
		event.dataTransfer.setData("Text", event.target.id);
}
function dragleave(event) {
		document.getElementById("showtext").innerHTML="leave...";
		
		if(event.target.tagName.toLowerCase() == "div") {
			event.target.style.border = "1px blue solid";  
		}
}
function dragenter(event) {
		document.getElementById("showtext").innerHTML = "into...";
		
		if(event.target.tagName.toLowerCase() == "div") {
			event.target.style.border = "1px red solid";  
		}
}
function dragover(event) {
		event.preventDefault();
}